﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Yupload
{
    class HanldeInterface
    {
        const string CHOOSEFILETITLE = "Select a Video";
        const string DELETEVIDEO = "Delete";

        public static int AddVideo(int index, Dictionary<string, Control> formControls)
        {
            string filePath = String.Empty;

            OpenFileDialog chooseFile = new OpenFileDialog();
            chooseFile.Title = CHOOSEFILETITLE;
            // TODO: Add Filter to Dialog
            chooseFile.InitialDirectory = Application.StartupPath;
            if (chooseFile.ShowDialog() == DialogResult.OK)
            {
                filePath = chooseFile.FileName;
                TextBox fileName = new TextBox();
                fileName.Height = 25;
                fileName.Width = 300;
                fileName.Top = 3;
                fileName.Left = 3;
                fileName.Text = filePath;
                fileName.Enabled = false;

                Button deleteVideo = new Button();
                deleteVideo.Text = DELETEVIDEO;
                deleteVideo.Width = 75;
                deleteVideo.Height = 23;
                deleteVideo.Top = 2;
                deleteVideo.Left = fileName.Width + fileName.Left + 3;

                formControls["btnAddVideo"].Top += 28;

                formControls["pnVideos"].Controls.Add(fileName);
                formControls["pnVideos"].Controls.Add(deleteVideo);

                return index + 1;
            }
            else
            {
                return index;
            }
        }
    }
}
